module.exports = function ($resource, $state, $http, $q, $scope, FileUploader, toaster, $modal) {
    /* 分页
    * ========================================= */
    $scope.maxSize = 5;             //最多显示多少个按钮
    $scope.bigCurrentPage = 1;      //当前页码
    $scope.itemsPerPage = 10         //每页显示几条
    $scope.searchform = {};
    // 区县
    $scope.districtArr = [
        {'label' : '和平区', 'value' : '0'},
        {'label' : '沈河区', 'value' : '1'},
        {'label' : '皇姑区 ', 'value' : '2'},
        {'label' : '铁西区', 'value' : '3'},
        {'label' : '大东区', 'value' : '4'},
        {'label' : '东陵区', 'value' : '5'},
        {'label' : '于洪区', 'value' : '6'},
        {'label' : '苏家屯区', 'value' : '7'},
        {'label' : '沈北新区', 'value' : '8'},
        {'label' : '浑南新区', 'value' : '9'},
        {'label' : '辽中县', 'value' : '10'},
        {'label' : '康平县', 'value' : '11'},
        {'label' : '法库县', 'value' : '12'},
        {'label' : '新民市', 'value' : '13'}
    ]
    $scope.getlist = function () {
        var para = {
            pageNo:$scope.bigCurrentPage, 
            pageSize:$scope.itemsPerPage
        };
        para = angular.extend($scope.searchform, para);
        $resource('/api/as/ggc/touristFundsCapitalApplyAd/findFinanceCapitalApplySuperviseList', {}, {}).
        save(para,function(res) {
            console.log(para);
            if (res.errcode !== 0) {
                toaster.error({title:"",body:res.errmsg});
                return;
            }
            console.log('数据');
            console.log(res);
            $scope.objs = res.data.results;
            $scope.bigTotalItems = res.data.totalRecord;
            $scope.objs.forEach(element => {
                for (var i = 0; i < $scope.districtArr.length; i++){
                  if (element.user_country == $scope.districtArr[i].value){
                    element.user_country_name = $scope.districtArr[i].label;
                  }
                }
            });
          
        })
    };
    $scope.getlist();

    $scope.detail = function(item) {
        $scope.item = item;
        var modalInstance = $modal.open({
          template: require('../views/superviseInfo.html'),
          controller: 'superviseInfo',
          size: 'lg',
          resolve: {
            item: function () {
                return $scope.item;
            },
          }
        });
        modalInstance.result.then(function (showResult) {	
            $scope.getlist();
        });
    };
    $scope.prohibit = function(apply_id){
        if(confirm('确定要对改企业禁止进行任何操作吗')){
            $resource('/api/as/ggc/touristFundsCapitalApplyAd/updateCapitalApplySuperviseOff', {}, {}).
            save({'apply_id' : apply_id},function(res) {
                if (res.errcode !== 0) {
                    toaster.error({title:"",body:res.errmsg});
                    return;
                }
                toaster.success({title:"",body:'禁止成功'});
                $scope.getlist();
            })
            return;
        } 
    }
    $scope.release = function(apply_id){
        if(confirm('确定要对改企业放行任何操作吗')){
            $resource('/api/as/ggc/touristFundsCapitalApplyAd/updateCapitalApplySuperviseOn', {}, {}).
            save({'apply_id' : apply_id},function(res) {
                if (res.errcode !== 0) {
                    toaster.error({title:"",body:res.errmsg});
                    return;
                }
                toaster.success({title:"",body:'放行成功'});
                $scope.getlist();
            })
            return;
        } 
    }
  

}